#include<bits/stdc++.h>
using namespace std;

struct st
{
    int d;
    int v;
    int a;
} car[1000005];

int det[1000005];
int wrn[1000005];
int spd[1000005];

int check(int vbound, int v0, int a, int s)
{
    int v;

    v = v0 * v0 + 2 * a * s;

    if(v > vbound * vbound)
    {
        return 1;
    }

    return 0;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    int t = 0;
    int n = 0, m = 0;
    int len = 0, vx = 0;

    cin >> t;

    for(int y = 1; y <= t; y++)
    {

        int cnt = 1;
        int res1 = 0, res2 = 0;

        memset(spd, 0, sizeof(spd));

        cin >> n >> m;
        cin >> len >> vx;

        for(int i = 1; i <= n; i++)
        {
            cin >> car[i].d >> car[i].v >> car[i].a;
        }

        for(int i = 1; i <= m; i++)
        {
            cin >> det[i];
        }

        sort(det + 1, det + m + 1);

        for(int i = 1; i <= n; i++)
        {
            if(car[i].a == 0)
            {
                if(car[i].v > vx)
                {
                    if(det[m] >= car[i].d)
                    {
                        spd[i] = 1;
                    }
                }
            }
            else
            {
                if(det[m] >= car[i].d)
                {
                    if(check(vx, car[i].v, car[i].a, det[m] - car[i].d) == 1)
                    {
                        spd[i] = 1;
                    }
                }

            }

        }


        for(int i = 1; i <= n; i++)
        {
            if(spd[i] == 1)
            {
                res1 ++;
            }
        }

        cout << res1;
        cout << " ";
        if(res1 == 0)
        {
            cout << m;
        }
        else
        {
            cout << m-1;
        }

        cout << endl;

    }



    fclose(stdin);
    fclose(stdout);

    return 0;

}
